﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;

namespace BUS
{
    public class BUS_NguoiDung
    {
        #region 1. Inserting
        public static bool ThemNguoiDung(DTO_NguoiDung nd)
        {
            //check
            return DAO_NguoiDung.ThemNguoiDung(nd);
        }
        #endregion
        #region 2. Delete
        public static bool XoaNguoiDung(DTO_NguoiDung nd)
        {
            //check
            return DAO_NguoiDung.XoaNguoiDung(nd);
        }
        #endregion
        #region 3. Check
        public static bool KiemTra(DTO_NguoiDung nd)
        {
            
            List<DTO_NguoiDung> lnd = new List<DTO_NguoiDung>();
            lnd = DAO_NguoiDung.LayTatCaNguoiDung();
            foreach (DTO_NguoiDung ndx in lnd)
            {
                if (string.Compare(nd.TenDangNhap, ndx.TenDangNhap) == 0 && string.Compare(nd.MatKhau, ndx.MatKhau) == 0)
                    return true;
                
                    
            }
            return false;
        }
        #endregion
        #region 4. Retrieving

        public static List<DTO_NguoiDung> LayTatCaNguoiDung()
        {
            return DAO_NguoiDung.LayTatCaNguoiDung();
        }
        #endregion
    }
}
